package com.fbs.wowo.forum.web;

import com.fbs.wowo.base.BaseController;
import com.fbs.wowo.base.Response;
import com.fbs.wowo.forum.entity.Likes;
import com.fbs.wowo.forum.service.LikesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/likes")
public class LikesController extends BaseController {

    @PostMapping("/like")
    public Response like(@ModelAttribute Likes likes) {
        return success(likesService.add(likes));
    }

    @PostMapping("/dislike")
    public Response dislike(@ModelAttribute Likes likes) {
        return success(likesService.minus(likes));
    }

    @GetMapping("/count")
    public Response likes(@RequestParam String entityId, @RequestParam Integer entityType) {
        return success(likesService.likes(entityId, entityType));
    }

    @Autowired
    private LikesService likesService;
}
